home *** CD-ROM | disk | FTP | other *** search
/ Aminet 41 / Aminet 41 (2001)(Schatztruhe)[!][Feb 2001].iso / Aminet / util / sys / 68040Lib.lha / 68040Lib / Install / BuildMMUConfig.rexx < prev    next >
OS/2 REXX Batch file  |  2000-07-29  |  15KB  |  364 lines

  1. /*********************************************************
  2.  ** BuildMMUConfig                    **
  3.  **                            **
  4.  ** Builds the MMU-Configuration file automatically    **
  5.  ** from the boards information, including kludges for    **
  6.  ** bad or mis-designed hardware            **
  7.  ** Version 1.10 © 2000 THOR-Software, Thomas Richter   **
  8.  ** 29.07.2000                                          **
  9.  ** with special thanks to Tobias Abt and Niels Knoop    **
  10.  ** for the Board Ids                    **
  11.  *********************************************************/
  12.  
  13. PARSE ARG destination p5disable .
  14.  
  15.     if (destination = '') then
  16.         destination = '*';
  17.  
  18.     p5 = 1;
  19.     if (upper(p5disable) = 'NOP5') then
  20.         p5 = 0;
  21.     
  22.     rec = 25;
  23.  
  24.     if (OPEN(.out,destination,'W')) THEN; DO
  25.         rv=WRITELN(.out,";*************************************************************************");
  26.         rv=WRITELN(.out,";** MMU Configuration file                                              **");
  27.         rv=WRITELN(.out,";**                                                                     **");
  28.         rv=WRITELN(.out,";** this file is read on startup by the mmu.library and used to modify  **");
  29.         rv=WRITELN(.out,";** the pre-calculated or scanned MMU table                             **");
  30.         rv=WRITELN(.out,";**                                                                     **");
  31.         rv=WRITELN(.out,";** © 1999,2000 THOR Software, Thomas Richter                           **");
  32.         rv=WRITELN(.out,";*************************************************************************");
  33.         rv=WRITELN(.out,"");
  34.         rv=WRITELN(.out,"");
  35.         rv=WRITELN(.out,"");
  36.         rv=WRITELN(.out,"; the current version of the MMU library knows four commands that can");
  37.         rv=WRITELN(.out,"; be used in this file:");
  38.         rv=WRITELN(.out,"; CLEARTTX clears all or parts of the transparent translation registers");
  39.         rv=WRITELN(.out,"; ADDMEM   adds memory to the exec free list pool. BE WARNED, this command");
  40.         rv=WRITELN(.out,";          does NOT modify the MMU tables, this must be done manually with");
  41.         rv=WRITELN(.out,";          SETCACHEMODE");
  42.         rv=WRITELN(.out,"; SETCACHEMODE  defines the MMU tables.");
  43.         rv=WRITELN(.out,"; DESCRIPTORCACHEINHIBIT defines whether the data cache should be disabled");
  44.         rv=WRITELN(.out,"; for the MMU descriptors. It's usually OFF meaning the cache will remain");
  45.         rv=WRITELN(.out,"; enabled. This is fine for the mmu.library, but certain hacks might require");
  46.         rv=WRITELN(.out,"; an ON argument here. Note that this means more work for the library.");
  47.         rv=WRITELN(.out,"");
  48.         rv=WRITELN(.out,"");
  49.         rv=WRITELN(.out,"ClearTTx        ;ignore all TTX registers if any. We don't need them");
  50.         rv=WRITELN(.out,"");
  51.         rv=WRITELN(.out,";DescriptorCacheInhibit ON    ;make access to MMU descriptors cache inhibited");        
  52.         rv=WRITELN(.out,"");
  53.         rv=WRITELN(.out,"");
  54.         rv=WRITELN(.out,";Board specific setup follows here,");
  55.         rv=WRITELN(.out,";generated by BuildMMUConfig 1.10 © 29.07.2000 THOR-Software");
  56.         rv=WRITELN(.out,"");
  57.  
  58.         rv=WRITELN(.out,";General memory setup follows.");
  59.         rv=WRITELN(.out,";The following lines are a compatibility kludge for some P5 boards");
  60.         rv=WRITELN(.out,";which enable the MMU prior to the 68040/68060 library and leave");
  61.         rv=WRITELN(.out,";the memory in CACHEINHIBIT state. You may remove the following");
  62.         rv=WRITELN(.out,";lines on all other machines most likely.");
  63.         rv=WRITELN(.out,"");
  64.  
  65.         ADDRESS COMMAND "MemModes >T:MemInfo";
  66.         IF (OPEN(.meminfo,"T:MemInfo",'R')) THEN; DO 
  67.             DO UNTIL EOF(.meminfo)
  68.                 line = READLN(.meminfo);
  69.                 rv = WRITELN(.out,line);
  70.             END;
  71.             rv=CLOSE(.meminfo);
  72.         END;
  73.         
  74.         rv=WRITELN(.out,";Memory setup end.");
  75.         rv=WRITELN(.out,"");
  76.         rv=WRITELN(.out,"");
  77.  
  78.         ADDRESS COMMAND "ShowBoards to T:BoardInfo";
  79.         IF (OPEN(.boardinfo,"T:BoardInfo",'R')) THEN; DO
  80.             rec = 0;
  81.             DO UNTIL EOF(.boardinfo)
  82.                 line = READLN(.boardinfo)
  83.                 IF line ~= '' THEN; DO
  84.                     PARSE VAR line 'Type:' type 'Product:' product 'Manufacturer:' mf 'Serial#:' id 'BoardAddr:' from 'BoardSize:' size;
  85.                     type=X2D(type);
  86.                     product=X2D(product);
  87.                     mf=X2D(mf);
  88.                     id=X2D(id);
  89.                     dfrom=X2D(from);
  90.                     dsize=X2D(size);
  91.                     from=STRIP(from);
  92.                     size=STRIP(size);
  93.                     rv=WRITELN(.out,";Setup for board "mf"/"product);
  94.                     rv=IdentifyBoard(type,product,mf,id,from,size,dfrom,dsize);
  95.                     rv=WRITELN(.out,"");    
  96.                 END
  97.             END    
  98.             rv=CLOSE(.boardinfo);
  99.         END
  100.  
  101.         /* P5 setup kludges follow here..... Sigh */
  102.  
  103.         romlibs        = 0;            /* libs in ROM? */
  104.  
  105.         IF p5 THEN; DO
  106.             ADDRESS COMMAND 'P5Identify'
  107.             p5mode         = RC;            /* Possibly P5 board? */
  108.             ADDRESS COMMAND 'FindPort "BOOT-MMU-Port"'
  109.             portmode     = RC;            /* MMU setup kludge? */
  110.             ADDRESS COMMAND 'FindResident "ppc.library"'
  111.             ppclibmode     = RC;            /* PPCLib in ROM? */
  112.             ADDRESS COMMAND 'FindResident "68060quick.library"'
  113.             quicklibmode     = RC;            /* quick lib in ROM? */
  114.             ADDRESS COMMAND 'FindResident "68060.library"'
  115.             libmode     = RC;            /* 060 lib in ROM? */
  116.             ADDRESS COMMAND 'FindResident "68040.library"'
  117.             lib4mode     = RC;            /* 040 lib in ROM? */
  118.  
  119.             IF p5mode ~= 0 THEN; DO
  120.                 p5init         = 1
  121.                 ppccheck    = 1
  122.             END;
  123.         
  124.             IF ppclibmode = 0 THEN; DO
  125.                 ppccheck    = 1
  126.             END;
  127.  
  128.             IF portmode = 0 THEN; DO
  129.                 ppccheck     = 1
  130.                 p5init         = 1
  131.             END;
  132.  
  133.             IF (quicklibmode = 0) | (libmode = 0) | (lib4mode = 0) | (ppclibmode = 0) THEN; DO
  134.                 p5init         = 1
  135.                 romlibs        = 1
  136.                 ppccheck    = 1
  137.             END;
  138.         END; ELSE; DO
  139.             p5init        = 0
  140.             romlibs        = 0
  141.             ppccheck    = 0
  142.         END;
  143.  
  144.         IF p5init = 1 THEN;DO
  145.             rv=WRITELN(.out,"");
  146.             rv=WRITELN(.out,";P5 fixes follow here:");
  147.             rv=WRITELN(.out,";If you do not own a P5 board, you may remove the following lines");
  148.             rv=WRITELN(.out,";");
  149.             rv=WRITELN(.out,";Several P5 boards build a private MMU setup on boot");
  150.             rv=WRITELN(.out,";using a kludge called the BOOT-MMU-Port. To run this");
  151.             rv=WRITELN(.out,";kludge, the following external command is run from");
  152.             rv=WRITELN(.out,";LIBS:mmu/ as all other external commands");
  153.             rv=WRITELN(.out,";");
  154.             rv=WRITELN(.out,";This command installs also other P5 relevant MMU settings");
  155.             rv=WRITELN(.out,";Hence, for P5 boards, please keep it in place even if");
  156.             rv=WRITELN(.out,";you *DO NOT* see the BOOT-MMU-Port.");
  157.             rv=WRITELN(.out,";");
  158.             IF ~EXISTS("LIBS:mmu") THEN; DO
  159.                 OPTIONS FAILAT 15
  160.                 ADDRESS COMMAND 'MakeDir >NIL: LIBS:MMU'
  161.                 OPTIONS FAILAT 10
  162.             END;
  163.             IF ~EXISTS("LIBS:mmu/P5Init") THEN; DO
  164.                 ADDRESS COMMAND 'Copy >NIL: P5Init to LIBS:MMU/P5Init'
  165.             END;
  166.             rv=WRITELN(.out,"P5Init");
  167.             rv=WRITELN(.out,"");
  168.             rv=WRITELN(.out,"");
  169.         END;            
  170.  
  171.         IF ppccheck = 1 THEN; DO
  172.             ADDRESS COMMAND 'PPCIdentify'
  173.             ppccheck = RC;
  174.         END;
  175.  
  176.         IF ppccheck = 1 THEN; DO
  177.             SAY "The setup script found a P5 board with PPC processor.";
  178.             SAY "While not a problem in general, please note that you";
  179.             SAY "absolutely *MUST NOT* use the ppc.library together";
  180.             SAY "with the mmu.library. This won't work.";
  181.         END;
  182.  
  183.         IF romlibs = 1 THEN; DO
  184.             rv=WRITELN(.out,"");
  185.             rv=WRITELN(.out,";This board has some processor libs resident");
  186.             rv=WRITELN(.out,";BPPCFix should be run to remove it.");
  187.             rv=WRITELN(.out,";This command has been installed into C:");
  188.             rv=WRITELN(.out,";by the setup script.");
  189.             SAY "The setup script found some processor libraries resident in ROM";
  190.             SAY "You will not be able to use the MuLib specific processor";
  191.             SAY "libraries unless you run BPPCFix in your startup-sequence.";
  192.             SAY "Please study the BPPCFix manual for details on how to run";
  193.             SAY "this program to replace the ROM-based libraries."
  194.             SAY "";
  195.             SAY "Note further that you *DO NOT* need the ENVARC:MMU-Configuration"
  196.             SAY "file if you continue to use the ROM resident libraries.";
  197.             SAY "";
  198.             IF ~EXISTS("C:BPPCFix") THEN; DO
  199.                 ADDRESS COMMAND 'Copy >NIL: BPPCFix to C:BPPCFix'
  200.                 SAY "Copied BPPCFix to C: for convenience...";
  201.             END;
  202.         END;
  203.  
  204.         rv=WRITELN(.out,"");
  205.         rv=CLOSE(.out);
  206.         ADDRESS COMMAND 'Delete T:BoardInfo QUIET'
  207.     END    
  208.  
  209. EXIT rec
  210.  
  211. IdentifyBoard:    PROCEDURE
  212. PARSE ARG type,product,mf,id,xfrom,xsize,from,size
  213.  
  214.     IF BitExtract(type,5) = '1' THEN; DO
  215.         rv=WRITELN(.out,";This board contains memory and requires no special threadment.");
  216.         rv=WRITELN(.out,";In case accessing this memory with COPYBACK enabled causes crashes,");
  217.         rv=WRITELN(.out,";please remove the semicolon in front of the next line:");
  218.         rv=WRITELN(.out,";SetCacheMode FROM 0x"xfrom" SIZE 0x"xsize" CACHEINHIBIT NONSERIAL IMPRECISE");
  219.         sp = 1;
  220.     END; ELSE; DO
  221.         z2 = 0
  222.         z3 = 0
  223.         if (from >= X2D('00200000')) & (from+size <= X2D('00A00000')) THEN; DO
  224.             z2 = 1;
  225.         END;
  226.         if (from >= X2D('10000000')) & (from+size <= X2D('7FFFFFFF')) THEN; DO
  227.             z3 = 1;
  228.         END;
  229.         IF (mf = 18260) & (product = 19) THEN; DO
  230.             rv=WRITELN(.out,";Altais");
  231.             rv=WRITELN(.out,"For 18260 19 SetCacheMode FROM {base} SIZE {size} CACHEINHIBIT NONSERIAL IMPRECISE");
  232.             sp = 1;
  233.         END;
  234.         IF (mf = 18260) & (product = 16) & z3 THEN; DO
  235.             rv=WRITELN(.out,";Retina Z3");
  236.             rv=WRITELN(.out,"For 18260 16 Z3 SetCacheMode FROM {base+0x00c00000} SIZE 0x00400000 CACHEINHIBIT NONSERIAL IMPRECISE");
  237.             sp = 1;
  238.         END;
  239.         IF (mf = 2117) & (product = 3) THEN; DO
  240.             rv=WRITELN(.out,";Merlin");
  241.             rv=WRITELN(.out,"For 2117 3 SetCacheMode FROM {base+0x00c00000} SIZE 0x00200000 CACHEINHIBIT NONSERIAL IMPRECISE");
  242.             sp = 1;
  243.         END;            
  244.         IF (mf = 2181) & (product = 0) & (size >= X2D('00100000')) & z2 THEN; DO
  245.             rv=WRITELN(.out,";oMniBus");
  246.             rv=WRITELN(.out,"For 2181 0 BIG SetCacheMode FROM {base+0x00c00000} SIZE 0x00200000 CACHEINHIBIT NONSERIAL IMPRECISE");
  247.             sp = 1;
  248.         END;            
  249.         IF (mf = 2092) & (product = 33) & z3 THEN; DO
  250.             rv=WRITELN(.out,";Graffity Z3");
  251.             rv=WRITELN(.out,"For 2092 33 Z3 SetCacheMode FROM {base+0x00c00000} SIZE 0x00200000 CACHEINHIBIT NONSERIAL IMPRECISE");
  252.             sp = 1;
  253.         END;
  254.         IF (mf = 2092) & (product = 33) & z2 THEN; DO
  255.             rv=WRITELN(.out,";Graffity Z2");
  256.             rv=WRITELN(.out,"For 2092 33 Z2 SetCacheMode FROM {base} SIZE {size} CACHEINHIBIT NONSERIAL IMPRECISE");
  257.             sp = 1;
  258.         END;        
  259.         IF (mf = 2167) & (product = 1) & z2 THEN; DO
  260.             rv=WRITELN(.out,";Domino");
  261.             rv=WRITELN(.out,"For 2167 1 Z2 SetCacheMode FROM {base} SIZE {size} CACHEINHIBIT NONSERIAL IMPRECISE");
  262.             sp = 1;
  263.         END;
  264.         IF (mf = 2167) & (product = 11) THEN; DO
  265.             rv=WRITELN(.out,";Picasso II");
  266.             rv=WRITELN(.out,"For 2167 11 SetCacheMode FROM {base} SIZE {size} CACHEINHIBIT NONSERIAL IMPRECISE");
  267.             sp = 1;
  268.         END;
  269.         IF (mf = 2167) & (product >= 21) & (product <= 24) THEN; DO
  270.             rv=WRITELN(.out,";Picasso IV");
  271.             rv=WRITELN(.out,";The PIV is too flexible in its design to allow a fixed MMU setup");
  272.             rv=WRITELN(.out,";but the P96 software will care about this board anyhow.");
  273.             sp = 1;
  274.         END;
  275.         IF (mf = 2193) & (product = 1) THEN; DO
  276.             rv=WRITELN(.out,";GVP Spectrum");
  277.             rv=WRITELN(.out,"For 2193 1 SetCacheMode FROM {base} SIZE {size} CACHEINHIBIT NONSERIAL IMPRECISE");
  278.             sp = 1;
  279.         END;
  280.         IF (mf = 2195) & (product = 5) THEN; DO
  281.             rv=WRITELN(.out,";Piccolo");
  282.             rv=WRITELN(.out,"For 2195 5 SetCacheMode FROM {base} SIZE {size} CACHEINHIBIT NONSERIAL IMPRECISE");
  283.             sp = 1;
  284.         END;
  285.         IF (mf = 2195) & (product = 10) & z2 THEN; DO
  286.             rv=WRITELN(.out,";Piccolo-SD64 Z2");
  287.             rv=WRITELN(.out,"For 2195 10 Z2 SetCacheMode FROM {base} SIZE {size} CACHEINHIBIT NONSERIAL IMPRECISE");
  288.             sp = 1;
  289.         END;
  290.         IF (mf = 2195) & (product = 10) & z3 THEN; DO
  291.             rv=WRITELN(.out,";Piccolo-SD64 Z3");
  292.             rv=WRITELN(.out,"For 2195 10 Z3 SetCacheMode FROM {base} SIZE 0x00400000 VALID IOSPACE CACHEINHIBIT NONSERIAL IMPRECISE");
  293.             sp = 1;
  294.         END;
  295.         IF (mf = 8512) & (product = 34) & z3 THEN; DO
  296.             sp = 1;
  297.             rv=WRITELN(.out,";CyberVision Z3");
  298.             rv=WRITELN(.out,"For 8512 34 Z3 SetCacheMode FROM {base} SIZE {size} BLANK IOSPACE");
  299.             rv=WRITELN(.out,"For 8512 34 Z3 SetCacheMode FROM {base} SIZE 0x01400000 VALID IOSPACE CACHEINHIBIT");
  300.             rv=WRITELN(.out,"For 8512 34 Z3 SetCacheMode FROM {base+0x01400000} SIZE 0x00c00000 VALID IOSPACE CACHEINHIBIT NONSERIAL IMPRECISE");
  301.             rv=WRITELN(.out,"For 8512 34 Z3 SetCacheMode FROM {base+0x02000000} SIZE 0x02000000 VALID IOSPACE CACHEINHIBIT");
  302.         END;
  303.         IF (mf = 8512) & (product = 67) THEN; DO
  304.             sp = 1;
  305.             rv=WRITELN(.out,";CyberVision3D");
  306.             rv=WRITELN(.out,"For 8512 67 SetCacheMode FROM {base} SIZE {size} BLANK IOSPACE");
  307.             IF Z2 THEN; DO
  308.                 rv=WRITELN(.out,"For 8512 67 Z2 SetCacheMode FROM {base} SIZE 0x00380000 VALID IOSPACE CACHEINHIBIT NONSERIAL IMPRECISE");
  309.                 rv=WRITELN(.out,"For 8512 67 Z2 SetCacheMode FROM {base+0x00380000} SIZE 0x00080000 VALID IOSPACE CACHEINHIBIT");
  310.             END; ELSE; DO
  311.                 rv=WRITELN(.out,"For 8512 67 Z3 SetCacheMode FROM {base+0x04000000} SIZE 0x01000000 VALID IOSPACE CACHEINHIBIT NONSERIAL IMPRECISE");
  312.                 rv=WRITELN(.out,"For 8512 67 Z3 SetCacheMode FROM {base+0x05000000} SIZE 0x00010000 VALID IOSPACE CACHEINHIBIT");
  313.                 rv=WRITELN(.out,"For 8512 67 Z3 SetCacheMode FROM {base+0x05800000} SIZE 0x00008000 VALID IOSPACE CACHEINHIBIT");
  314.                 rv=WRITELN(.out,"For 8512 67 Z3 SetCacheMode FROM {base+0x07000000} SIZE 0x00008000 VALID IOSPACE CACHEINHIBIT");
  315.                 rv=WRITELN(.out,"For 8512 67 Z3 SetCacheMode FROM {base+0x08000000} SIZE 0x00001000 VALID IOSPACE CACHEINHIBIT");
  316.                 rv=WRITELN(.out,"For 8512 67 Z3 SetCacheMode FROM {base+0x0C000000} SIZE 0x00010000 VALID IOSPACE CACHEINHIBIT");
  317.                 rv=WRITELN(.out,"For 8512 67 Z3 SetCacheMode FROM {base+0x0C0E0000} SIZE 0x00001000 VALID IOSPACE CACHEINHIBIT");
  318.             END
  319.         END;    
  320.         IF (mf = 2145) & (product = 33) THEN; DO
  321.             sp = 1;
  322.             rv=WRITELN(.out,";Rainbow III");
  323.             rv=WRITELN(.out,"For 2145 33 SetCacheMode FROM {base} SIZE {size} BLANK IOSPACE");
  324.             rv=WRITELN(.out,"For 2145 33 SetCacheMode FROM {base} SIZE 0x00400000 VALID IOSPACE CACHEINHIBIT");
  325.         END;
  326.         IF (mf = 8512) & (product = 100) THEN; DO
  327.             sp = 1;
  328.             rv=WRITELN(.out,";MK-III SCSI Hostadapter");
  329.             rv=WRITELN(.out,"For 8512 100 SetCacheMode FROM {base} SIZE {size} VALID IOSPACE CACHEINHIBIT");
  330.         END;
  331.         IF (mf = 8512) & (product = 110) THEN; DO
  332.             sp = 1;
  333.             rv=WRITELN(.out,";Blizzard PPC SCSI Hostadapter");
  334.             rv=WRITELN(.out,"For 8512 110 SetCacheMode FROM {base} SIZE {size} VALID IOSPACE CACHEINHIBIT");
  335.         END;
  336.         IF (sp = 0) THEN; DO
  337.             rv=WRITELN(.out,";no special care has been taken for this board.");
  338.         END;
  339.         
  340.     END    
  341.  
  342. RETURN 0
  343.  
  344. ;
  345. ; The AREXX BITTST function seems to be broken. We implement our own
  346. ;
  347. BitExtract:    PROCEDURE
  348. PARSE ARG num,bit
  349.     bit=SUBSTR(C2B(D2C(num)),8-bit,1);
  350. RETURN bit
  351.  
  352. ;
  353. ; ARexx uses floating point addition and causes a mess about it when
  354. ; converting this back to integer. Therefore, we use another approach for
  355. ; adding numbers.
  356. ; Luckely, boards are aligned...
  357. Add:        PROCEDURE
  358. PARSE ARG base,offset
  359.     offset = LEFT(offset,LENGTH(offset)-2)
  360.     base   = LEFT(base,LENGTH(base)-2)
  361.     base   = D2X(X2D(offset)+X2D(base))'00'
  362. RETURN base
  363.  
  364.